/**
 * 
 */
package edu.gatech.datastorage;

import java.io.Serializable;

import edu.gatech.utilities.Persistence;

/**
 * A treatment record that stores appointment date/time, the 
 * nurse and doctor seen, symptoms, vital signs, etc.
 * One of these is made for each office visit.
 * @author Dan Holdridge
 * @version 1.0
 */
public class TreatmentRecord implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4205252781891259768L;

	/**
	 * The Appointment the treatment record is for
	 */
	private Appointment appointment;
	
	/**
	 * The name of the doctor seen
	 */
	private String doctor;
	
	/**
	 * The name of the nurse seen
	 */
	private String nurse;
	
	/**
	 * The DoctorsOrders issued
	 */
	private DoctorsOrders orders;
	
	/**
	 * The symptons the patient is suffering from
	 */
	private String symptoms;
	
	/**
	 * Information like blood pressure, temperature, etc
	 */
	private String vitalSigns;
	
	/**
	 * The final diagnosis the doctor gives
	 */
	private String diagnosis;
	
	/**Invoice attached to the treatment**/
	private Invoice invoice;
	
	/**
	 * Constant 2
	 */
	private static final int TWO = 2;

    /**
     * Constant 3
     */
    private static final int THREE = 3;
    
	/**
	 * Creates a new TreatmentRecord by adding a new appointment
	 * @param reason String containing the reason the 
	 * patient is seeing the doctor
	 * @param date String the date of the appointment
	 * @param time String the time of the appointment
	 * @param desiredDoc String the name of the doctor the patient
	 * wishes to see
	 */
	public TreatmentRecord(String reason, String date, String time, String desiredDoc){
		this.appointment = new Appointment(reason, date, time, desiredDoc);
	}
	
	/**
	 * @see java.lang.Object#toString()
	 * @return The date of the appointment
	 */
	public String toString(){
		
		final String[] vitalSigns = this.vitalSigns.split(" ");
		final String height = vitalSigns[TWO];
		final String weight = vitalSigns[THREE];
		final String bloodPreassure = vitalSigns[0];
		final String temperature = vitalSigns[1];
		return "Appointment: " + appointment.getDate() + " " + appointment.getTime() +
		"\nDoctor: " + this.getDoctor() + "\nNurse: " + this.getNurse() 
		+ "\nSymptoms: " + this.getSymptoms() + 
		"\nHeight: " + height + " Weight: " + weight + 
		"\nBloodPreassure: " + bloodPreassure + " Temperature: " + 
		temperature + "\nDiagnosis: " + this.getDiagnosis();
	}

	/**
	 * @return the appointment
	 */
	public Appointment getAppointment() {
		return appointment;
	}

	/**
	 * @param appointment the appointment to set
	 */
	public void setAppointment(Appointment appointment) {
		this.appointment = appointment;
	}

	/**
	 * @return the doctor
	 */
	public String getDoctor() {
		return doctor;
	}

	/**
	 * @param doctor the doctor to set
	 */
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}

	/**
	 * @return the nurse
	 */
	public String getNurse() {
		return nurse;
	}

	/**
	 * @param nurse the nurse to set
	 */
	public void setNurse(String nurse) {
		this.nurse = nurse;
	}

	/**
	 * @return the orders
	 */
	public DoctorsOrders getOrders() {
		return orders;
	}

	/**
	 * @param orders the orders to set
	 */
	public void setOrders(DoctorsOrders orders) {
		this.orders = orders;
	}

	/**
	 * @return the symptoms
	 */
	public String getSymptoms() {
		return symptoms;
	}

	/**
	 * @param symptoms the symptoms to set
	 */
	public void setSymptoms(String symptoms) {
		this.symptoms = symptoms;
	}

	/**
	 * @return the vitalSigns
	 */
	public String getVitalSigns() {
		return vitalSigns;
	}

	/**
	 * @param vitalSigns the vitalSigns to set
	 */
	public void setVitalSigns(String vitalSigns) {
		this.vitalSigns = vitalSigns;
	}

	/**
	 * @return the diagnosis
	 */
	public String getDiagnosis() {
		return diagnosis;
	}

	/**
	 * @param diagnosis the diagnosis to set
	 */
	public void setDiagnosis(String diagnosis) {
		this.diagnosis = diagnosis;
	}

	/**Sets the invoice
	 * 
	 * @param invoice
	 */
	public void setInvoice(Invoice invoice) {
		this.invoice = invoice;
	}

	/** Gets the invoice for the treatment
	 * 
	 * @return Invoice
	 */
	public Invoice getInvoice() {
		return invoice;
	}

	/**
	 * Deletes an appointment
	 */
	public void deleteAppointment(){
		setAppointment(null);
	}
	
	/**Edits a treatment record by setting
	 *  a new appointment
	 * @param reason
	 * @param date
	 * @param time
	 * @param desiredDoc
	 */
	public void edit(String reason, String date, String time, String desiredDoc){
		setAppointment(new Appointment(reason, date, time, desiredDoc));
	}
	
	/**
	 * Deletes the doctors orders
	 */
	public void deleteOrders(){
		setOrders(null);
		Persistence.save();
	}
}
